// question.entity.ts
import { BaseEntity } from 'src/common/base.entity';
import { Survey } from 'src/modules/survey/entities/survey.entity';
import {
    Entity,
    Column,
    Unique,
    PrimaryGeneratedColumn,
    Index,
    ManyToOne,
} from 'typeorm';

@Entity({ name: 'question', comment: '题目表' })
// @Unique(['question_id',]) // 在数据库层面添加唯一性约束
export class Question extends BaseEntity {
    // @Column({ type: 'int', comment: '题目索引', unique: true })
    // @Index("IDX_QUESTION_INDEX", { unique: true })
    // questionIndex: number = 1;
 
    @Column({ type: 'varchar', length: 255, comment: '题目内容' })
    question: string;

    @Column({ type: 'varchar', length: 255, comment: '选项1' })
    option1: string;

    @Column({ type: 'varchar', length: 255, comment: '选项2' })
    option2: string;

    @Column({ type: 'varchar', length: 255, comment: '选项3' })
    option3: string;

    @Column({ type: 'varchar', length: 255, comment: '选项4' })
    option4: string;

    @Column({ type: 'varchar', length: 255, comment: '正确答案' })
    correctAnswer: string;

    @ManyToOne(() => Survey, survey => survey.questions)
    survey: Survey;
}
